package com.example.controller;


import com.example.entity.Books;
import com.example.service.IBooksService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jcl
 * @since 2021-08-21
 */
@RestController
@RequestMapping("/books")
public class BooksController {
    @Autowired
    private IBooksService iBooksService;

    @RequestMapping("/list")//1qaz@WSX3edc
    public List<Books> list(){
        return iBooksService.list();
    }
    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable("id") Integer id){
        return iBooksService.removeById(id);
    }
    @GetMapping("/find/{id}")
    public Books findid(@PathVariable("id") Integer id){
        return iBooksService.getById(id);
    }
    @PutMapping("/update")
    public boolean update(@RequestBody Books books){
        return iBooksService.updateById(books);
    }
    @RequestMapping("/add")
    public boolean add(@RequestBody Books books){
        return iBooksService.save(books);
    }

}

